<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">
      

	<ui:composition template="../template.xhtml">
		<ui:define name="conteudo">
			<p:ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>
				<p:dialog modal="true" widgetVar="statusDialog" header="Status"   
			        draggable="false" closable="false">  
				    <h:outputText value="Aguarde..." /> 
			</p:dialog>  
			<div id="location">Associação</div>
			<div id="container">
				<div id="form">
					<h:form id="associacaoForm">
	       					<div class="fundo">
								<fieldset>
									<legend>Busca</legend>
										<p:messages id="growl" showDetail="true" showSummary="false" />
										
											<label style="width: 300px;">
												<p>Razão Social:</p>
												<p:inputText value="#{associacaoMB.associacao.razaoSocial}" styleClass="campoBusca"/>
											</label>
											<label style="width: 150px;">
												<p>CPF/CNPJ:</p>
												<p:inputText value="#{associacaoMB.associacao.cdPess}" styleClass="campoBusca" onkeypress="return fnEvnEntradaNumeros();" maxlength="14"/>
											</label>									
											<div style="padding-top: 20px">
												<p:spacer width="10"/>
												<p:commandButton action="#{associacaoMB.buscar}" value="Buscar" update="associacaoListaForm"/>
												<p:spacer width="10"/>
												<p:commandButton value="Novo" action="#{associacaoMB.paginaNovo}" ajax="false"/>
											</div>
								</fieldset>	
								<p:spacer height="20"/>	
							</div>
					</h:form>
				</div>
			</div>
				
			<div id="container">
				<div id="form">
					<h:form id="associacaoListaForm">
	       					<div class="fundo">
								<fieldset>
									<legend>Resultado</legend>
									<p:dataTable 
										value="#{associacaoMB.associacaoList}" 
										var="ass" 
										emptyMessage="Nenhuma Associação Encontrada."
										id="tabela"
										rowStyleClass="#{empty rowIx or rowIx mod 2 ne 0 ? 'even-row' : 'odd-row'}" 
										rowIndexVar="rowIx">
										<p:column style="width: 20px;">
											<p:commandButton action="#{associacaoMB.paginaAlterar}" title="Editar" image="ui-icon ui-icon-pencil">
												<f:setPropertyActionListener value="#{ass}" target="#{associacaoMB.associacaoSelecionada}" />
											</p:commandButton>
										</p:column>
										<p:column style="text-align: left;" sortBy="#{ass.razaoSocial}">
											<f:facet name="header">
												Razão Social
											</f:facet>
											<h:outputText value="#{ass.razaoSocial}" />
										</p:column>
										<p:column style="text-align: left;" sortBy="#{ass.cdPess}">
											<f:facet name="header">
												CPF/CNPJ
											</f:facet>
											<h:outputText value="#{ass.cdPess}" />
										</p:column>
										
									</p:dataTable>
								</fieldset>
								<p:spacer height="20"/>
							</div>
					</h:form>
				</div>
			</div>
		</ui:define>
	</ui:composition>
</html>